function lookmore(obj) {
    var facility = $(obj).parents('li').find('.facility');
    console.log(facility);
    if (!facility.hasClass('show')) {
        facility.removeClass('hidden').addClass('show');
        $(obj).html('收起');
    } else if (facility.hasClass('show')) {
        facility.addClass('hidden').removeClass('show');
        $(obj).html('查看更多');
    }
}

function loadinfo(obj) {
    $(obj).addClass('weui-bar__item_on show').siblings().removeClass('weui-bar__item_on show');
    $('#roomList').html('');
    loading.show();
    loading.content('数据加载中...');
    var id = $(obj).attr('roomid');
    console.log(id);
    var data = {
        type: 'GET',
        url: 'http://vkwechat.mebaby.cn/app/index.php?i=2&c=entry&do=ApiGetSpaceListByType&m=orange_spacerental&type_id=' + id,
        data: 'null',
        dcallback: function (res) {
            var html = '';
            $.each(res.data, function (i, p) {
                var facility = '';
                if (p.have_projection == 1) {
                    facility += '<div> ' +
                        '<span class="icon icon-projector"></span><span class="facility-name">投影</span> ' +
                        '        </div> ';
                }
                if (p.have_sound == 1) {
                    facility += '        <div> ' +
                        '<span class="icon icon-sound"></span><span class="facility-name">音响</span> ' +
                        '        </div> ';
                }
                if (p.have_drinking == 1) {
                    facility += '  <div>' +
                        '<span class="icon icon-water"></span><span class="facility-name">饮水机</span> ' +
                        '        </div> '
                }
                // console.log(facility);
                html += '<li roominfoid="' + p.id + '">' +
                    '    <a href="http://vkwechat.mebaby.cn/app/index.php?i=2&c=entry&do=SpaceRentalApply&m=orange_spacerental&space_id=' + p.id + '">' +
                    '        <div class="facility-desc"> ' +
                    '        <div class="list-img"> ' +
                    '        <img class= "ListPhoto " src="' + p.space_pic + '"  alt=""> ' +
                    '        </div> ' +
                    '        <div class="list-det"> ' +
                    '        <p>' + p.space_name + '</p> ' +
                    '        <div class="btn-box-right"> ' +
                    '        <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default" onclick="lookmore(this)">查看更多</a> ' +
                    '        </div> ' +
                    '        </div> ' +
                    '        </div> ' +
                    '        <div class="facility hidden"> ' +
                    '        <p>座位数：' + p.seats_number + '</p> ' +
                    '        <div class="facility-det"> ' + facility + '</div> ' +
                    '        <div class="btn-box-book"> ' +
                    '        <a href="http://vkwechat.mebaby.cn/app/index.php?i=2&c=entry&do=SpaceRentalApply&m=orange_spacerental&space_id=' + p.id + '" class="weui-btn weui-btn_mini weui-btn_primary">我要预订</a> ' +
                    '        </div> ' +
                    '        </div> ' +
                    '        </a> ' +
                    '        </li>'

            });
            $('#roomList').html(html);
            loading.hide();
        }
    }
    vankehttps(data);
}
window.onload=function(){
    $('.weui-navbar__item').first().addClass('weui-bar__item_on show');
    loadinfo('.weui-bar__item_on');

}